﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Text;

namespace DAL
{
    public  class ReportScoreDAL
    {
        /// <summary>
        /// 记录测试人员维度得分。
        /// </summary>
        public static int RecordScore(string  tester_sn, int tester_dimensionid, int tester_dimensionscore, DateTime dim_startDateTime, DateTime dim_endDateTime)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into ExamDB.dbo.tb_Report_Score(");
            strSql.Append(@"tester_sn,
                            tester_dimensionid,
                            tester_dimensionscore,
                            dim_startDateTime,
                            dim_endDateTime)");

            strSql.Append(" values (");

            strSql.Append(@"@tester_sn,
                            @tester_dimensionid,
                            @tester_dimensionscore,
                            @dim_startDateTime,
                            @dim_endDateTime)");

            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters = {
					new SqlParameter("@tester_sn", SqlDbType.NVarChar,255),
					new SqlParameter("@tester_dimensionid", SqlDbType.Int,4),
					new SqlParameter("@tester_dimensionscore", SqlDbType.Int,4),
					new SqlParameter("@dim_startDateTime", SqlDbType.DateTime),
                    new SqlParameter("@dim_endDateTime", SqlDbType.DateTime),
                                        };
            parameters[0].Value = tester_sn;
            parameters[1].Value = tester_dimensionid;
            parameters[2].Value = tester_dimensionscore;
            parameters[3].Value = dim_startDateTime;
            parameters[4].Value = dim_endDateTime;
            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
            if (obj == null)
            {
                return -1;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
    }
}
